package com.csdn.eval.spring.mqtt.demo.controller;

import com.csdn.eval.spring.mqtt.core.MqttGatewayPublish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo")
public class DemoController {

    @Autowired
    private MqttGatewayPublish<String> mqttGatewayPublish;

    @RequestMapping("/hello")
    public String hello() {
        mqttGatewayPublish.publish("hello/topic", "Hello, MQTT!");
        return "Hello, Spring MQTT Demo!";
    }
}
